﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;

namespace Enterprise.Management.ViewModels
{
    public class CreateUserViewModel
    {
        [Required(ErrorMessage = "必填项")]
        [Display(Name = "用户类型")]
        public int User_RoleID { get; set; }

        [Display(Name = "分公司")]
        public int? User_CtgrID { get; set; }

        [Required(ErrorMessage = "必填项")]
        [RegularExpression(@"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$", ErrorMessage = "邮件格式不对")]
        [Display(Name = "用户邮箱")]
        public string User_Email { get; set; }

        [Required(ErrorMessage = "必填项")]
        [StringLength(20, ErrorMessage = "长度不对", MinimumLength = 0)]
        [Display(Name = "用户名")]
        public string User_Name { get; set; }

        public SelectList Roles { get; set; }
        public SelectList Categories { get; set; }
    }

    public class CreateCategoryViewModel
    {
        [Required(ErrorMessage = "请指定分公司")]
        [Display(Name = "所属分公司")]
        public int Category_ID { get; set; }

        [Required(ErrorMessage = "必填项")]
        [StringLength(20, ErrorMessage = "长度不对", MinimumLength = 0)]
        [Display(Name = "营业部名称")]
        public string Category_Name { get; set; }

        [Required(ErrorMessage = "必填项")]
        [RegularExpression(@"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$", ErrorMessage = "邮件格式不对")]
        [Display(Name = "营业部负责人邮箱")]
        public string User_Email { get; set; }

        public SelectList Categories { get; set; }
    }

    public class UpdateUserViewModel
    {
        public int User_ID { get; set; }
        public int Category_Level { get; set; }

        [Required(ErrorMessage = "必填项")]
        [StringLength(20, ErrorMessage = "长度不对", MinimumLength = 0)]
        [Display(Name = "用户名")]
        public string User_Name { get; set; }

        [Required(ErrorMessage = "必填项")]
        [RegularExpression(@"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$", ErrorMessage = "邮件格式不对")]
        [Display(Name = "用户邮箱")]
        public string User_Email { get; set; }

        [Display(Name = "是否为用户重置密码")]
        public bool IsResetPwd { get; set; }
    }
}